# -*- coding: utf-8 -*-
import logging

def logger_init (verbosity):
    # 本身使用的logger
    logger =logging.getLogger() 
    logger.setLevel (logging.DEBUG)
    # create stream handler
    sh = logging.StreamHandler ()
    if verbosity == 3: 
        sh.setLevel(logging.DEBUG) 
    elif verbosity == 2:
        sh.setLevel(logging.INFO) 
    elif verbosity == 1:
        sh.setLevel(logging.WARNING) 
    elif verbosity == 0:
        sh.setLevel(logging.ERROR)
    # create formatter
    formatter = __get_log_formatter() 
    sh.setFormatter(formatter)
    logger.addHandler (sh)

def __get_log_formatter(): 
    fmt ='[%(asctime)s %(levelname)s %(funcName)s %(filename)s:%(lineno)d] %(message)s'
    dateFmt ='%H:%M:%S'
    return logging.Formatter(fmt, dateFmt)
